<template>
    <div>
        <a-modal
         :visible="visibleShow" 
         :title="formState.id?'编辑':'新增'" 
         @ok="handleOk" 
         @cancel="visibleShow = false">
            <a-form
                :form="form" 
                v-if="visibleShow"
            >
                <a-form-item label="序号">
                    <a-input v-model:value="formState.forder" placeholder="请输入序号"/>
                </a-form-item>
                <a-form-item label="人员类型">
                    <a-input
                    v-model:value="formState.frylx"
                    placeholder="请输入人员类型"
                    v-decorator="[
                        'frylx', { initialValue:formState.frylx, rules: rules.frylx}
                    ]"/>
                </a-form-item>
            </a-form>
         </a-modal>
    </div>
</template>
<script>
import {addServe,editServe} from './service/index'
export default {
    components:{

    },
    props:{

    },
    data(){
        return{
            visibleShow:false,
            formState:{},
            form: this.$form.createForm(this, { name: 'coordinated' }),
            rules:{
                frylx: [{
                    required: true,
                    message: '请输入人员类型',
                    trigger: 'blur',
                }],
            },
        }
    },
    watch:{

    },
    mounted(){
        
    },
    methods:{
        getData(row){
            this.formState = {}
            this.formState = row
        },
        handleOk(){
            this.form.validateFields((err, values) => {
                if(!err){
                    if(this.formState.id){
                        editServe(this.formState).then(res=>{
                            if(res.code == 200){
                                this.$message.success(res.message)
                                this.visibleShow = false
                                this.$emit('increaseRefresh')
                            }else{
                                this.$message.warning(res.message)
                            }
                        })
                    }else{
                        addServe(this.formState).then(res=>{
                            if(res.code == 200){
                                this.$message.success(res.message)
                                this.visibleShow = false
                                this.$emit('increaseRefresh')
                            }else{
                                this.$message.warning(res.message)
                            }
                        })
                    }
                }
            })
        }
    }
}
</script>